-
Notifications
You must be signed in to change notification settings - Fork 950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
metal: Set preserveInvariance for shader options #2372
Conversation
Not sure what the webgpu spec says about these accuracy issues, but I'm guessing that disabling fastMath itself shouldn't be needed, but |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First the user code is expected to put [[invariant]]
on the position output for this to be portable.
Honestly, my preference was to just force it unconditionally, but the group wanted it to be optional.
Then, given [[invariant]]
the implementations are expected to do the thing, but MSL doesn't universally support it, so it becomes an unofficial best-effort scenario.
That is to say, I'm fully on board with calling set_preserve_invariance
whenever it's available.
Ah, so the "right" way to do it, is to add But I suppose it is not currently doing that in naga? |
Right, unfortunately. Filed gfx-rs/naga#1659 to follow-up. |
f364de1
to
e052572
Compare
I actually thought the
So, it needs both the flag and the decoration? But just the option still seems to fix the issues? I don't get it? Also for the older versions, it says
|
Oh fun! I wonder if it's a new edit. Anyway, looks like a mess, but we should proceed with the same plan. I.e. we'll always set |
This enables invariance for metal, for stable vertex positions, which are useful for depth prepass and similiar things.
e052572
to
7543c2e
Compare
Cleaned out the possibly misleading comment. Ok now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
published in wgpu-hal-0.12.3 |
This fixes, for example, depth prepass resulting in ever so slightly
different depth values for later render passes.
Connections
BVE-Reborn/rend3#317
Description
By default, metal enables "fastMath" optimizations for shaders, which may result in ever so slightly values for, for example depth, or other values. Setting the
preserveInvariance
pessimizes this for vertex shader locations, so that depth prepasses work consistently.Testing
With rend3 examples